home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue51 / Construc / DataMod.pas < prev    next >
Pascal/Delphi Source File  |  1999-09-27  |  3KB  |  112 lines

  1. unit DataMod;
  2. interface
  3. uses
  4.   Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom, DataBkr,
  5.   DBClient, Server51_TLB, StdVcl, Provider, Db, DBTables;
  6.  
  7. type
  8.   TTDM = class(TRemoteDataModule, ITDM)
  9.     CustomerTable: TTable;
  10.     OrdersTable: TTable;
  11.     CustomerTableCustNo: TFloatField;
  12.     CustomerTableCompany: TStringField;
  13.     CustomerTableAddr1: TStringField;
  14.     CustomerTableAddr2: TStringField;
  15.     CustomerTableCity: TStringField;
  16.     CustomerTableState: TStringField;
  17.     CustomerTableZip: TStringField;
  18.     CustomerTableCountry: TStringField;
  19.     CustomerTablePhone: TStringField;
  20.     CustomerTableFAX: TStringField;
  21.     CustomerTableTaxRate: TFloatField;
  22.     CustomerTableContact: TStringField;
  23.     CustomerTableLastInvoiceDate: TDateTimeField;
  24.     OrdersTableOrderNo: TFloatField;
  25.     OrdersTableCustNo: TFloatField;
  26.     OrdersTableSaleDate: TDateTimeField;
  27.     OrdersTableShipDate: TDateTimeField;
  28.     OrdersTableEmpNo: TIntegerField;
  29.     OrdersTableShipToContact: TStringField;
  30.     OrdersTableShipToAddr1: TStringField;
  31.     OrdersTableShipToAddr2: TStringField;
  32.     OrdersTableShipToCity: TStringField;
  33.     OrdersTableShipToState: TStringField;
  34.     OrdersTableShipToZip: TStringField;
  35.     OrdersTableShipToCountry: TStringField;
  36.     OrdersTableShipToPhone: TStringField;
  37.     OrdersTableShipVIA: TStringField;
  38.     OrdersTablePO: TStringField;
  39.     OrdersTableTerms: TStringField;
  40.     OrdersTablePaymentMethod: TStringField;
  41.     OrdersTableItemsTotal: TCurrencyField;
  42.     OrdersTableTaxRate: TFloatField;
  43.     OrdersTableFreight: TCurrencyField;
  44.     OrdersTableAmountPaid: TCurrencyField;
  45.     DataSource1: TDataSource;
  46.     CustomerOrdersProvider: TDataSetProvider;
  47.     Session1: TSession;
  48.     procedure CustomerOrdersProviderBeforeGetRecords(Sender: TObject;
  49.       var OwnerData: OleVariant);
  50.     procedure CustomerTableScroll(DataSet: TDataSet);
  51.   private
  52.     { Private declarations }
  53.   protected
  54.     class procedure UpdateRegistry(Register: Boolean; const ClassID, ProgID: string); override;
  55.   public
  56.     { Public declarations }
  57.   end;
  58.  
  59. implementation
  60. {$R *.DFM}
  61. uses
  62.   MainUnit;
  63.  
  64. class procedure TTDM.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
  65. begin
  66.   if Register then
  67.   begin
  68.     inherited UpdateRegistry(Register, ClassID, ProgID);
  69.     EnableSocketTransport(ClassID);
  70.     EnableWebTransport(ClassID);
  71.   end else
  72.   begin
  73.     DisableSocketTransport(ClassID);
  74.     DisableWebTransport(ClassID);
  75.     inherited UpdateRegistry(Register, ClassID, ProgID);
  76.   end;
  77. end;
  78.  
  79. procedure TTDM.CustomerOrdersProviderBeforeGetRecords(Sender: TObject;
  80.   var OwnerData: OleVariant);
  81. var
  82.   RecNo: Integer;
  83. begin
  84.   if OwnerData <> '' then
  85.   begin
  86.     RecNo := OwnerData;
  87.     Log('Init: '+IntToStr(RecNo));
  88.     with (Sender AS TDataSetProvider) do
  89.     begin
  90.       DataSet.First;
  91.       while (RecNo > 0) and not DataSet.Eof do
  92.       begin
  93.         Dec(RecNo);
  94.         Log('Next: '+IntToStr(RecNo));
  95.         DataSet.Next
  96.       end
  97.     end
  98.   end
  99.   else Log('Empty!')
  100. end;
  101.  
  102. procedure TTDM.CustomerTableScroll(DataSet: TDataSet);
  103. begin
  104.   Log('AfterScroll: '+IntToStr(DataSet.RecNo))
  105. end;
  106.  
  107. initialization
  108.   TComponentFactory.Create(ComServer, TTDM,
  109.     Class_TDM, ciMultiInstance, tmApartment);
  110. end.
  111.  
  112.